<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
	<ui:composition template="/design/template.xhtml">
    <ui:define name="body">

      <h:form id="frmConcursoQuestao" acceptcharset="ISO-8859-1">
      <h:inputHidden id="codigoConcursoQuestao" value="#{adminConcursoQuestaoAction.concursoMateria.codigo}"/> 
      <p:panel id="pnlConcursoQuestao" header="Questão Concurso">

        <p:spacer height="10" />
        <p:messages id="messages" autoUpdate="true" />

        <h:panelGrid columns="3" cellpadding="4" >

          <h:outputText value="Complemento:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:editor id="edtComplemento" value="#{adminConcursoQuestaoAction.questao.complemento.texto}" width="530" height="200" 
                controls="bold italic underline strikethrough subscript superscript | font size | color highlight removeformat | alignleft center alignright justify | undo redo | pastetext | source" >
          </p:editor>  

          <h:outputText value="Texto:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:editor id="edtTexto" value="#{adminConcursoQuestaoAction.questao.texto}" width="530" height="200" 
                required="true" requiredMessage="Texto obrigatório!" 
                controls="bold italic underline strikethrough subscript superscript | font size | color highlight removeformat | alignleft center alignright justify | undo redo | pastetext | source" >
          </p:editor>  
          
          <h:outputText value="Itens:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:dataTable id="tblQuestaoItens" value="#{adminConcursoQuestaoAction.questao.listaItens}" var="questaoItem" >
            <p:column>
              <p:selectBooleanCheckbox id="checkItemCorreto" value="#{questaoItem.itemCorreto}" >
              </p:selectBooleanCheckbox>
            </p:column>
            <p:column>
              <p:spacer width="5" />
              <p:inputText id="identificadorItem" value="#{questaoItem.identificador}" style="width:20px;" required="true"
                requiredMessage="Identificador obrigatório!" maxlength="2" >
              </p:inputText>
              <p:spacer width="10" />
              <p:inputText id="textoItem" value="#{questaoItem.texto}" style="width:360px;" required="true" 
                requiredMessage="Texto obrigatório!">
              </p:inputText>
              <p:spacer width="5" />
            </p:column>
            <p:column>
              <p:commandLink id="lnkDeleteItem" update=":dlgConfirm" oncomplete="varDlgConfirm.show()" >
                <h:graphicImage value="/images/action_desabled.gif" width="16" height="16" style="border: 0px;" title="excluir item" />
                <f:setPropertyActionListener value="#{questaoItem}" target="#{adminConcursoQuestaoAction.questaoItem}" />            
              </p:commandLink>
            </p:column>
          </p:dataTable>

          <p:spacer width="1" />
          <p:spacer width="6" />
          <h:commandLink action="#{adminConcursoQuestaoAction.adicionarItem}" value="adicionar item" style="width:350px;" />

          <h:outputText value="Comentario:" styleClass="formLabel" />
          <p:spacer width="6" />
          <p:inputTextarea id="comentarioQuestao" value="#{adminConcursoQuestaoAction.questao.comentario}" rows="5" cols="100" />

        </h:panelGrid>
        <p:spacer height="10" />
        <p:outputPanel id="pnlButons">
          <div align="left" id="divButons">
            <p:commandButton action="#{adminConcursoQuestaoAction.listar}" value="cancelar" ajax="false" immediate="true" />
            <p:spacer width="10" />
            <p:commandButton action="#{adminConcursoQuestaoAction.incluir}" update="pnlConcursoQuestao" value="incluir" ajax="false" rendered="#{adminConcursoQuestaoAction.acaoIncluir}" />
            <p:commandButton action="#{adminConcursoQuestaoAction.alterar}" update="pnlConcursoQuestao" value="alterar" ajax="false" rendered="#{adminConcursoQuestaoAction.acaoAlterar}" />
          </div>
        </p:outputPanel>			

    </p:panel>
    </h:form>

    <p:dialog widgetVar="varDlgConfirm" id="dlgConfirm" header="Confirmação" modal="true" resizable="false" draggable="false" width="250">
      <p:outputPanel id="pnlConfirm">  
      <table width="100%">
        <tbody>
          <tr>
            <td align="center" colspan="2" width="100%">
              <h:outputText value="Confirma excluir item?" ></h:outputText>
            </td>
          </tr>
          <tr>
            <td align="center" colspan="2" width="100%">
              <h:outputText style="font-weight:bold" value="#{adminConcursoQuestaoAction.questaoItem.codigo} - #{adminConcursoQuestaoAction.questaoItem.identificador}" ></h:outputText>
            </td>
          </tr>
          <tr>
            <td align="center" colspan="2" width="100%" height="10"></td>
          </tr>
          <tr>
            <td align="center" width="50%">
              <p:commandButton value="confirmar" action="#{adminConcursoQuestaoAction.excluirItem}" update=":frmConcursoQuestao:tblQuestaoItens" oncomplete="varDlgConfirm.hide();" />
            </td>
            <td align="center" width="50%">
              <p:commandButton value="cancelar" onclick="varDlgConfirm.hide();" />
            </td>
          </tr>
        </tbody>
      </table>
      </p:outputPanel>
    </p:dialog>

  </ui:define>
  </ui:composition>
</html>
